<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link href="${res_app}/css/wuxi.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
	<script type="text/javascript" src="${res}/gezComponents/popupDiv/showDialog.js"></script>

	<script type="text/javascript" src="${res}/js/public.js"></script>
	<script type="text/javascript" src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
	<title>申请书审核</title>
	<style type="text/css">
		.button_orange {
			height:25px; font-size:12px; color:#cc3300; border:1px #cc9933 solid;
			background:url(${res}/images/button_orange.gif); padding:0 15px; *padding:0 10px;
			_padding:0 10px; cursor: pointer;
		}
		.soBox1 { padding:10px 15px; border: 1px solid #F0CDCC; background:#fffdf4; overflow:hidden; }
		.mask {
			position: absolute; top: 0px; filter: alpha(opacity=60); background-color: #777;
			z-index: 1002; left: 0px;
			opacity:0.5; -moz-opacity:0.5;
		}
	</style>
</head>
<body>

<security:authorize ifAnyGranted="A_AUTH_SCS">
	<cpt:helpTips key="prpapproveTips4scs" id="prpapproveTips4scs"></cpt:helpTips>
	<div class="clear_h10"></div>
</security:authorize>
<input type="hidden" id="childDiv" class="thickbox" />
<form method="post" id="mainForm">
	<input type="hidden" id="prpCodes" name="prpCodes" value="" />
	<input type="hidden" id="type" name="type" value="" />
</form>
<div class="soBox">
	<div class="detail ico_search">
		<table>
			<tr>
				<td rowspan="2"><strong>检索条件：</strong>
				</td>
				<security:authorize ifNotGranted="A_AUTH_DW,A_AUTH_DEPT">
					<td>
						<cpt:search key="prpApprove_search4org_chushi"  repeatColumn="3" displayCount="6" leftStyle="width:80px"></cpt:search>
					</td>
				</security:authorize>
				<security:authorize ifAnyGranted="A_AUTH_DW,A_AUTH_DEPT">
					<td>
						<cpt:search key="prpApprove_search4org"  repeatColumn="3" displayCount="6" leftStyle="width:100px"></cpt:search>
					</td>
				</security:authorize>
			</tr>
			<tr>
				<td>
					<div class="clear_h10"></div>
					<input type='button' id='searchBt' class="button_an" value='查询' />
				</td>
			</tr>

		</table>
	</div>
</div>
<div class="clear_h10"></div>
<div>
	<div id='TopBarMnt'></div>
	<table id='dataGrid'></table>
	<div id='dataBar'></div>
</div>
<div id="mask" class="mask"></div>
<script type="text/javascript">
	var irisGrid = new IrisGrid("dataGrid", "dataBar", 'TopBarMnt');
	var prcWin = new progressWin("${res}");//初始化遮罩层

	//兼容火狐、IE8
	//显示遮罩层
	function showMask(){
		$("#mask").css("height",$(document).height());
		$("#mask").css("width",$(document).width());
		$("#mask").show();
	}
	//隐藏遮罩层
	function hideMask(){

		$("#mask").hide();
	}

	var getSelOpt = function() {
		var g = "";
		$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
			if (obj.checked) {
				g += "," + obj.id.replace("jqg_dataGrid_", "");
			}
		});
		if (g != "") {
			g = g.substring(1);
		}
		return $.trim(g);
	};

	function showApproveDialog(type, gridObj, selectIdArray, recordRows){
		var prpCodes= getSelOpt();
		if(recordRows==''){
			prpCodes=selectIdArray+'';
		}
		if(prpCodes==""){
			scmWarn("请选择一条记录");
			return false;
		}

		if(type=="approve"){

			if(!checkSelect(selectIdArray)){
				return false;
			}
		}

		if(type=="approve"){

			var prpnum = prpCodes.split(",").length;
			$("#prpCodes").val(prpCodes);
			$("#type").val(type);
			var options = {
				beforeSubmit : function() {
					prcWin.openWin();//打开遮罩层
					$("#approve").attr("disabled",true);
				}, // 表单提交前的回调函数
				success : function(msg) {
					prcWin.closeWin();
					scmSuccess(msg);
					irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
					$("#approve").attr("disabled",false);
				},// 表单成功提交后的回调函数
				error : function() {
					scmError("操作失败,请联系系统管理员");
					prcWin.closeWin();
					$("#approve").attr("disabled",false);
				},
				url: "${ctx}/prpapprove/"+type
			};
			if(confirm("是否确认此"+prpnum+"份申请书?"+str+"")){
				var url="${ctx}/prpapprove/openprpapprovedialog?category=A&prpCodes="+prpCodes+"&type="+type+"&TB_iframe=true&height=250&width=410";
				var title="申报审核意见（最多为500字）";
				showThickBox(url,title);
				//$("#mainForm").ajaxSubmit(options);
			}
			else{
				return;
			}

		}else{
			if(prpCodes.split(",").length>1){
				scmError("退回操作限制只能单个退回");
				return false;
			}

			var url="${ctx}/prpapprove/openprpapprovedialog?category=A&prpCodes="+prpCodes+"&type="+type+"&TB_iframe=true&height=250&width=410";
			var title="申报审核意见（最多为500字）";
			showThickBox(url,title);
		}

	}

	function checkSelect(selectArray){
		var checked = 1;
		$("#approve").removeAttr("disabled");//去除该属性
		var grantcodeStr = "";
		var statYearStr = "";
		for(var i=0;i<selectArray.length;i++){
			var status=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"13");
			var flagCan=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"14");
			var grantCode=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"15");
			var statyear=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"16");
			if(status=="05"){
				scmWarn("您所选择的这"+selectArray.length+"份申请书中有部分申请书已受理，不允许重复确认!");
				checked = 0;
				break;
			}else if(status=='04'&&flagCan=="0") {
				scmWarn("您所选择的这"+selectArray.length+"份申请书中有部分申请书的正式PDF未生成，请在生成之后再选择该申请书进行受理操作");
				checked = 0;
				break;
			}else{
				grantcodeStr += ","+grantCode;
				statYearStr += ","+statyear;
			}
		}
		if(checked==0){
			return false;
		}else if(grantcodeStr!=""){
			return checklimitInfo(grantcodeStr,statYearStr);
		}
		return true;
	}

	function closeDialog(){
		tb_remove();
	}


	/** 表格初始化**/
	//loadIrisGrid("${res}");
	function buildGrid() {

		var columnAttrList = new Array();



		columnAttr = new ColumnAttr("项目类别", "grant_name","grant_name", 4, "left", true);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("项目名称", "zh_title","zh_title", 6, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
		columnAttrList.push(columnAttr);

// 			columnAttr = new ColumnAttr("项目类型", "proposal_type_name","proposal_type_name", 3, "center", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
// 			columnAttrList.push(columnAttr);

		<security:authorize ifNotGranted="A_AUTH_DW">
		columnAttr = new ColumnAttr("申报单位", "org_name","org_name", 6, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
		columnAttrList.push(columnAttr);
		</security:authorize>
		<security:authorize ifAnyGranted="A_AUTH_SCS">
		columnAttr = new ColumnAttr("所在区市", "area_name","area_name", 3, "center", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
		columnAttrList.push(columnAttr);
		</security:authorize>
		columnAttr = new ColumnAttr("项目负责人", "psn_name","psn_name", 3, "center", true);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("技术领域", "researcharea_name","researcharea_name", 3, "center", true);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("专题名称", "domain_name","domain_name", 3, "center", true);
		columnAttrList.push(columnAttr);


		columnAttr = new ColumnAttr("提交时间", "submitDate", "submit_date", 3,"left", true);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("水印号", "prp_version","prp_version", 3, "left", true);
		columnAttrList.push(columnAttr);

       <security:authorize ifAnyGranted="A_AUTH_TJBM,A_AUTH_ADMIN">
		columnAttr = new ColumnAttr("归口审核截止日期", "rec_date","rec_date", 3, "left", true);
		columnAttrList.push(columnAttr);
		</security:authorize>


		columnAttr = new ColumnAttr("工作进度", "statusName", "status", 5,"center", true);
		columnAttrList.push(columnAttr);

		//columnAttr = new ColumnAttr("进度查看", "status", "status", 5,"center", true);
		//columnAttrList.push(columnAttr);
		columnAttr = new ColumnAttr("审核意见", "comment", "comment", 3,"center", false);
		columnAttrList.push(columnAttr);

		<security:authorize ifAnyGranted="A_AUTH_SCZJ,A_AUTH_SCS">
		columnAttr = new ColumnAttr("项目比对", "fitCompare", "fitCompare", 3,"center", false);
		columnAttrList.push(columnAttr);
		</security:authorize>

		columnAttr = new ColumnAttr("PDF", "pdf", "pdf", 5,"center", false);
		columnAttrList.push(columnAttr);

		<security:authorize ifAnyGranted="A_AUTH_TJBM,A_AUTH_ADMIN">
		columnAttr = new ColumnAttr("失信比对", "", "", 3,"center", false);
		columnAttrList.push(columnAttr);
		</security:authorize>

		columnAttr = new ColumnAttr("操作", "", "", 3,"center", false);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("status", "status", "status", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);
		columnAttr = new ColumnAttr("flagCan", "flagCan", "flagCan", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);
		columnAttr = new ColumnAttr("grantCode", "grantCode", "grantCode", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);
		columnAttr = new ColumnAttr("statYear", "statYear", "statYear", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);



		columnAttr = new ColumnAttr("posCode", "posCode", "posCode", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("grantCode", "grantCode", "grantCode", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("subGrantCode", "subGrantCode", "subGrantCode", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("prpCode", "", "", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);

		columnAttr = new ColumnAttr("prpCode", "", "", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);
		/*审核退回参数passFlag*/
		columnAttr = new ColumnAttr("passFlag", "", "", 3,"left", false,false,"text",true);
		columnAttrList.push(columnAttr);

		irisGrid.setColumnAttrs(columnAttrList);
		//打印汇总表功能关闭
		/*  irisGrid.setToolsBar([
           {
              id : 'report',
              name : '打印汇总表',
              trigger : function(gridObj, selectIdArray, recordRows){//按钮onclick方法
                    showReportDialog("report", gridObj, selectIdArray, recordRows);
            }
           }]);
          */
		irisGrid.setToolsBar([
			{
				id : 'approve',
				<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
				name : '同意上报',
				</security:authorize>
				<security:authorize ifAnyGranted="A_AUTH_TJBM,A_AUTH_ZGDW">
				name : '审核通过',
				</security:authorize>

				trigger : function(gridObj, selectIdArray, recordRows){//按钮onclick方法
					var checkflag = true;
					var prpCodes = getSelOpt();
					var prpCode = prpCodes.split(",");
					for ( var i = 0; i < prpCode.length; i++) {
						var creditResult = $("#isDishonestCheckPass_" + prpCode[i]).val();
						if(creditResult == '0' || creditResult == '2'){
							alert("所选项目中包含失信项目，请通过最右侧按钮操作");
							return ;
						}
					}
					prpCodes = prpCodes + "";
					var num = 0;
					var ps = prpCodes.split(",");
					<security:authorize ifAnyGranted="A_AUTH_TJBM">
					checkRecommendLimit("approve", gridObj, selectIdArray, recordRows);
					</security:authorize>
					<security:authorize ifAnyGranted="A_AUTH_DW">
					checkOrgRecommendLimit("approve", gridObj, selectIdArray, recordRows);
					</security:authorize>
					<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
					<security:authorize ifNotGranted="A_AUTH_DW">
					showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
					</security:authorize>
					</security:authorize>
				}
			},
			{
				id : 'turnBack',
				name : '退回修改',
				trigger : function(gridObj, selectIdArray, recordRows){//按钮onclick方法
					showApproveDialog2("turnBack", gridObj, selectIdArray, recordRows);
				}
			}
			<security:authorize ifAnyGranted="A_AUTH_TJBM">
			,
			{
				id : 'notpass',
				name : '不同意申报',
				trigger : function(gridObj, selectIdArray, recordRows){//按钮onclick方法
					showApproveDialog2("notpass", gridObj, selectIdArray, recordRows);
				}
			}
			,
			{
				id : 'viewRecommends',
				name : '查看推荐情况 ',
				trigger : viewRecommends
			}
			</security:authorize>
			<security:authorize ifAnyGranted="A_AUTH_DW">
			,
			{
				id : 'viewOrgRecommends',
				name : '查看推荐情况 ',
				trigger : viewOrgRecommends
			}
			</security:authorize>
		]);

		irisGrid.setUrl("${ctx}/prpapprove/list-for-org?stat_year=${param.stat_year}");//查询url
		irisGrid.setCaption("暂写");
		irisGrid.setDefaultSortName("status,NLSSORT(zh_title,'NLS_SORT = SCHINESE_PINYIN_M')");//默认排序字段
		irisGrid.setDefaultSortorder("asc");
		irisGrid.setWidth(978);//整个表格宽度
		irisGrid.setCheckAble(true);//表格左边是否要复选框
		irisGrid.setShowRowIndex(true);//是否显示行号
		irisGrid.setQueryBox('searchBt', <security:authorize ifNotGranted="A_AUTH_DW,A_AUTH_DEPT">'prpApprove_search4org_chushi'</security:authorize><security:authorize ifAnyGranted="A_AUTH_DW,A_AUTH_DEPT">'prpApprove_search4org'</security:authorize>);//查询条件 按钮名，查询条件function_key
		irisGrid.setLoadComplete(setGray);
		irisGrid.onSelectAll = function(selectid,isSelect){//全选事件
			checkSelectAll();
		};

		<%--irisGrid.onSelectRow = function(selectid,isSelect){//审核项目--%>
		<%--//alert(selectid);--%>
		<%--//selectid = encodeURIComponent(selectid);--%>
		<%--//alert(selectid);--%>
		<%--var backFlag = $("#"+selectid+"_backFlag").val();--%>
		<%--// if(backFlag == 'YES')return;--%>


		<%--var posCode = $("#posCode_"+selectid).val();--%>
		<%--var grantCode = $("#grantCode_"+selectid).val();--%>
		<%--var subGrantCode = $("#subGrantCode_"+selectid).val();--%>
		<%--var curDate = "${curDate}";--%>
		<%----%>
		<%--var pcode= $("#prp_Code_"+selectid).val();--%>


		<%--//判断该项目是否有退回过--%>
		<%--var backDate = $("#backDate_"+selectid).val();--%>
		<%--var isback = 0;--%>
		<%--if(backDate!=null&&backDate!=''){--%>
		<%--isback = 1;--%>
		<%--}--%>
		<%--var roleId = "${roleId}";--%>
		<%--var off_code = "${off_code}";--%>
		<%--var dialogUrl = "${ctx}/prpapprove/openprpapprovedialog?category=A&off_code="+off_code+"&backFlag="+backFlag+"&roleId="+roleId+"&isback="+isback+"&curDate="+curDate+"&prpCodes="+pcode+"&posCode="+posCode+"&grantCode="+grantCode+"&subGrantCode="+subGrantCode+"&TB_iframe=true&height=250&width=410";--%>
		<%--window.open(dialogUrl,'newwin');--%>
		<%--};--%>

		irisGrid.onSelectAll = function(selectid, isSelect) {//全选事件
			checkSelectAll();
		}
		irisGrid.onSelectRow = function(selectid, isSelect) {//选择事件
			checkSelectAll2(selectid);
		}
		irisGrid.build();
	}

	function viewRecommends() {
		tb_show("推荐情况表",ctx+'/prpapprove/listOrgRecommends?flag=init&TB_iframe=true&height=520&width=978');
		$(parent.document).find("#TB_ajaxWindowTitle").text("推荐情况表");
	}

	function viewOrgRecommends() {
		tb_show("推荐情况表",ctx+'/prpapprove/listOrgSbdwRecommends?flag=init&TB_iframe=true&height=520&width=978');
		$(parent.document).find("#TB_ajaxWindowTitle").text("推荐情况表");
	}

	function showApproveDialog(pcode,passFlag){
		var selectid= pcode;
		var selectid2= passFlag;

		var isDishonestChecking = "0";
		var creditFlag = "1";
		var executionOrg = "";
		var executionNo = "";
		var infodate = "";
		var uniqueId = "";
		<security:authorize ifAnyGranted="A_AUTH_TJBM,A_AUTH_ADMIN">
		isDishonestChecking = $("#isDishonestChecking_" + selectid).val();
		if (isDishonestChecking === "1") {
			alert("失信比对中，请稍后");
			return;
		}
		creditFlag = $("#isDishonestCheckPass_" + selectid).val();

		if (creditFlag === "0") {
			executionOrg = $("#executionOrg_" + selectid).val();
			executionNo = $("#executionNo_" + selectid).val();
			infodate = $("#infodate_" + selectid).val();
			uniqueId = $("#uniqueId_" + selectid).val();
		}
		</security:authorize>

		var selectid= pcode;
		var curDate = "${curDate}";
		var roleId = "${roleId}";
		var off_code = "${off_code}";
		var posCode = $("#posCode_"+selectid).val();

		var grant_type= $("#grant_type_"+selectid).val();
		var grantCode = $("#grantCode_"+selectid).val();
		var subGrantCode = $("#subGrantCode_"+selectid).val();
		var status = $("#status_"+selectid).text();
		var passFlag = $("#passFlag_"+selectid2).val();
		/*	var passFlag = $("#passflag_"+selectid).val();*/


		var dialogUrl = "${ctx}/prpapprove/openprpapprovedialog?category=A&grant_type=" + grant_type + "&off_code=" + off_code + "&roleId=" + roleId + "&status=" + status + "&curDate=" + curDate + "&prpCodes=" + pcode + "&posCode=" + posCode + "&grantCode=" + grantCode + "&subGrantCode=" + subGrantCode;
		dialogUrl += "&passFlag=" + passFlag + "&creditFlag=" + creditFlag + "&executionOrg=" + executionOrg + "&executionNo=" + executionNo + "&infodate=" + infodate + "&uniqueId=" + uniqueId;
		dialogUrl += "&TB_iframe=true&height=250&width=410"
		window.open(dialogUrl, 'newwin');

	}

	/**
	 * 归口部门项限校验
	 */
	function checkRecommendLimit(type, gridObj, selectIdArray, recordRows) {
		var prpCodes = getSelOpt();
		if (recordRows == '') {
			prpCodes = selectIdArray + '';
		}
		if (prpCodes == "") {
			scmWarn("请选择一条记录");
			return false;
		}
		$.ajax({
			type: "POST",
			async:false,
			url: "${ctx}/prpapprove/approvesConfirm",
			data: {"prpCodes":prpCodes},
			beforeSend:function(XMLHttpRequest) {
				showMask();
// 		        	  prcWin.openWin();//打开遮罩层
			},
			success: function(msg){
				hideMask();
// 		        	   prcWin.closeWin();
				var obj = eval("(" + msg + ")");
				if(obj.isAllNoLimit == "nolimit") { // 如果所有的都没有限制 ，那么直接提交审批
					showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
					return;
				}
				if(obj.isAllPass == "pass") {
					if(window.confirm(obj.subject)){
						showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
					} else {
						return false;
					}
				} else if(obj.isAllPass == "notpass") {
					window.alert(obj.subject);
				}

			},// 表单成功提交后的回调函数
			error : function() {
				scmError("操作失败,请联系系统管理员");
				$("input[type='button'][id!='back']").attr("disabled",false);
				prcWin.closeWin();
			}
		});
	}


	/*function checkPrpCode() {
		var prpCodes = getSelOpt();
		if (prpCodes == "") {
			scmWarn("类别为空，请连接");
			return false;
		}
		$.ajax({
			type: "POST",
			async:false,
			url: "${ctx}/prpapprove/approvesConfirm",
			data: {"prpCodes":prpCodes},
			beforeSend:function(XMLHttpRequest) {
				showMask();
			},
			success: function(msg){
				hideMask();
				var obj = eval("(" + msg + ")");
				if(obj.isAllNoLimit == "nolimit") { // 如果所有的都没有限制 ，那么直接提交审批
					showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
					return;
				}
				if(obj.isAllPass == "pass") {
					if(window.confirm(obj.subject)){
						showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
					} else {
						return false;
					}
				} else if(obj.isAllPass == "notpass") {
					window.alert(obj.subject);
				}

			},// 表单成功提交后的回调函数
			error : function() {
				scmError("操作失败,请联系系统管理员");
				$("input[type='button'][id!='back']").attr("disabled",false);
				prcWin.closeWin();
			}
		});
	}*/
	/**
	 * 单位项限校验
	 */
	function checkOrgRecommendLimit(type, gridObj, selectIdArray, recordRows) {
		var prpCodes = getSelOpt();
		if (recordRows == '') {
			prpCodes = selectIdArray + '';
		}
		if (prpCodes == "") {
			scmWarn("请选择一条记录");
			return false;
		}
		$.ajax({
			type: "POST",
			async:false,
			url: "${ctx}/prpapprove/approvesConfirmOrg",
			data: {"prpCodes":prpCodes},
			beforeSend:function(XMLHttpRequest) {
				prcWin.openWin();//打开遮罩层
			},
			success: function(msg){
				var obj = eval("(" + msg + ")");
				prcWin.closeWin();
				if(obj.isAllNoLimit == "nolimit") { // 如果所有的都没有限制 ，那么直接提交审批
					showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
					return;
				}

				if(obj.isAllPass == "pass") {
					if(window.confirm(obj.subject)){
						showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
					} else {
						return false;
					}
				} else if(obj.isAllPass == "notpass") {
					window.alert(obj.subject);
				}

			},// 表单成功提交后的回调函数
			error : function() {
				scmError("操作失败,请联系系统管理员");
				$("input[type='button'][id!='back']").attr("disabled",false);
				prcWin.closeWin();
			}
		});
	}


	function showApproveDialog2(type, gridObj, selectIdArray, recordRows) {
		var prpCodes = getSelOpt();

		if (recordRows == '') {
			prpCodes = selectIdArray + '';
		}
		if (prpCodes == "") {
			scmWarn("请选择一条记录");
			return false;
		}

		var prpCode = prpCodes.split(",");
		for ( var i = 0; i < prpCode.length; i++) {
			var creditResult = $("#isDishonestCheckPass_" + prpCode[i]).val();
			if(creditResult == '0' || creditResult == '2'){
				alert("所选项目中包含失信项目，请通过最右侧按钮操作");
				return ;
			}
		}

		var passflags =getSelOpt2();
		/*var passflag =passflags.split(",");*/
		/*for ( var i = 0; i < passflag.length; i++) {
            var passflag = $("#passFlag_" + passflag[i]).val();*/
		if(passflags.indexOf("0") != -1 ){
			var str="归口审核时间截止后，退回修改的申报书再提交将不能在归口审核通过。（如有特殊情况，科技厅会另行通知）";
		}else{
			var str="";
		}

		if (type == "approve") {

			var prpnum = prpCodes.split(",").length;
			<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
			if (confirm("是否确认同意上报此" + prpnum + "份申请书?")) {
				</security:authorize>
				<security:authorize ifAnyGranted="A_AUTH_TJBM,A_AUTH_ZGDW">
				if (confirm("是否确认审核通过此" + prpnum + "份申请书?")) {
					</security:authorize>

					<security:authorize ifAnyGranted="A_AUTH_TJBM">
					var url = "${ctx}/prpapprove/audit-operate?prpCodes="+prpCodes+"&status=02"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>

					<security:authorize ifAnyGranted="A_AUTH_ZGDW">
					var url = "${ctx}/prpapprove/audit-operate?prpCodes="+prpCodes+"&status=03"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>

					<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
					var url = "${ctx}/prpapprove/audit-operate?prpCodes="+prpCodes+"&status=01,95"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>

					tb_show("申报书审核意见（最多为500字）", url, false);
				}
			}else if (type == "turnBack") {
				var prpnum = prpCodes.split(",").length;
				if (confirm("是否确认退回此" + prpnum + "份申请书? "+str+"")) {
					<security:authorize ifAnyGranted="A_AUTH_TJBM">
					var url = "${ctx}/prpapprove/audit-operate?prpCodes="+prpCodes+"&status=02"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					<security:authorize ifAnyGranted="A_AUTH_ZGDW">
					var url = "${ctx}/prpapprove/audit-operate?prpCodes="+prpCodes+"&status=03"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
					var url = "${ctx}/prpapprove/audit-operate?prpCodes="+prpCodes+"&status=01,95"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					tb_show("申报书退回意见（最多为500字）", url, false);
				}
			}

			else if (type == "notpass") {
				var prpnum = prpCodes.split(",").length;
				if (confirm("确定不同意申报吗？如果确定，此" + prpnum + "份申请书将作废。")) {
					<security:authorize ifAnyGranted="A_AUTH_TJBM">
					var url = "${ctx}/prpapprove/audit-operate?prpCodes="+prpCodes+"&status=02"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					tb_show("申报书退回意见（最多为500字）", url, false);
					</security:authorize>
				}
			}else {
				return;
			}

		}



		function checkSelectAll(){
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if($(obj).attr("disabled")){
					$(obj).attr("checked",false);
				}
			});
		}

		var getSelOpt = function() {
			var g = "";
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if (obj.checked) {
					g += "," + obj.id.replace("jqg_dataGrid_", "");
				}
			});
			if (g != "") {
				g = g.substring(1);
			}
			return $.trim(g);
		};

		var getSelOpt2 = function () {
			var g = "";
			$("input:checkbox[id^=jqg_dataGrid_]").each(function (i, obj) {
				if (obj.checked) {
					/*	g += "," + $(obj).id.parent("tr").find('input[id^="passFlag_"]').val();*/
					/*	g += "," + $(obj).parent("tr").find('input[id^="passFlag_"]').val();*/

					g+=","+	$(obj).parent('td').parent('tr').find("td input[id^='passFlag_']").val();
					/*/!*g += "," + obj.id.replace("passFlag_", "");*!/*/

					/*var id = $(obj).id.replace("jqg_dataGrid_", "");*/
				}
			});
			if (g != "") {
				g = g.substring(1);
			}
			return $.trim(g);
		};




		jQuery(function() {
			if("${prpstatus}"!=""){
				try{
					$("#_dyn_criteria2_field").val("prpstatus");
					_dyn_ShowCriteriaTag(document.getElementById("_dyn_criteria2_field"));
					$("#prpstatus").val("${prpstatus}");
				}catch(ee){}
			}

			if("${audie_date}"!=""){
				try{
					$("#_dyn_criteria2_field").val("audie_date");
					_dyn_ShowCriteriaTag(document.getElementById("_dyn_criteria2_field"));
					$("#audie_date").val("${audie_date}");
				}catch(ee){}
			}

			buildGrid();
			//	if($.browser.msie && $.browser.version<8)
			//	$("#return").addClass("button_orange").css("margin-left","166px");
			//	else
			//	$("#return").addClass("button_orange").css("margin-left","157px");

		});
		/** 表格初始化**/


		function interval2() {

			var clearPswTip2 = window.setInterval(function() {
				try {
					var dishonestPrpCodes = getChecked2();
					if (dishonestPrpCodes != "") {
						getCheckDishonest(dishonestPrpCodes);
					}
					if (dishonestPrpCodes == "") {
						window.clearInterval(clearPswTip);
					}

				} catch (e) {
					window.clearInterval(clearPswTip2);
				}
			}, 2500);
		}

		var getChecked2 = function() {
			var g = "";
			$("input[id^=isDishonestChecking_]").each(function(i, obj) {
				if ($(this).val() == 1) {
					g += "," + obj.id.replace("isDishonestChecking_", "");
				}
			});
			if (g != "") {
				g = g.substring(1);
			}
			return $.trim(g);
		};

		function getCheckDishonest(prpCodes) {
			var options = {
				type : 'post',
				data : {
					'prpCodes' : prpCodes
				},
				beforeSend : function() {
				},
				success : function(msg) {
					if (msg == 'SQLError' || msg == 'error') {

					} else {
						for ( var i = 0; i < msg.length; i++) {
							var tips="";
							if(msg[i].isCreditChecking == 1){
								tips = '<span class="color_red ico_wait">检查中...</span>';
								$("#isDishonestChecking_"+$.trim(msg[i].prpCode)).val("1");
								$("#isDishonestCheckPass_"+$.trim(msg[i].prpCode)).val("2");
							}else{
								if(msg[i].isDishonestCheckPass == 1){
									tips = '<span class="color_green">非失信项目</span>';
									$("#isDishonestChecking_"+$.trim(msg[i].prpCode)).val("0");
									$("#isDishonestCheckPass_"+$.trim(msg[i].prpCode)).val("1");
								}else if(msg[i].isDishonestCheckPass == 0){
									tips += '<a href="#" onclick="showCreditDetail('+"'"+$.trim(msg[i].prpCode)+"'"+');">';
									tips += '<span class="color_red">失信项目</span>';
									tips += '</a>';
									$("#isDishonestChecking_"+$.trim(msg[i].prpCode)).val("0");
									$("#isDishonestCheckPass_"+$.trim(msg[i].prpCode)).val("0");

									$("#uniqueId_"+$.trim(msg[i].prpCode)).val(msg[i].unique_id);
									$("#executionOrg_"+$.trim(msg[i].prpCode)).val(msg[i].execution_basis_org);
									$("#infodate_"+$.trim(msg[i].prpCode)).val(msg[i].infodate);
									$("#executionNo_"+$.trim(msg[i].prpCode)).val(msg[i].execution_no);
									$("#zh_name_"+$.trim(msg[i].prpCode)).val(msg[i].zh_name);
									$("#farenOrnot_"+$.trim(msg[i].prpCode)).val(msg[i].farenOrnot);
									$("#card_type_"+$.trim(msg[i].prpCode)).val(msg[i].card_type);
									$("#card_code_"+$.trim(msg[i].prpCode)).val(msg[i].card_code);
									$("#effect_name_"+$.trim(msg[i].prpCode)).val(msg[i].effect_name);
								}else{
									tips = '<span class="color_red">对比失败</span>';
									$("#isDishonestChecking_"+$.trim(msg[i].prpCode)).val("0");
									$("#isDishonestCheckPass_"+$.trim(msg[i].prpCode)).val("2");
								}
							}
							setDisabledOrNot($.trim(msg[i].prpCode));//编辑限制
							$("#dishonestCheck_"+$.trim(msg[i].prpCode)).html(tips);
						}
					}
				},
				error : function() {

				},
				url : ctx + "/appProject/getDishonestCheckInfoByPrpCode"
			};
			$.ajax(options);
		}

		function setDisabledOrNot(prp) {
			//项目比对标志（1：检查中，0：检查完毕）
			var isDishonestChecking = $("#isDishonestChecking_" + $.trim(prp));

			var jqg_dataGrid = "jqg_dataGrid_" + $.trim(prp); //选择框

			if(isDishonestChecking.val() == '1'){
				//置灰选择框
				disableArea(jqg_dataGrid);
			}else{
				enableArea(jqg_dataGrid);
			}

			/*以往业务逻辑 从setGray中迁移至此  */
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				var grant_type = $(this).parents("tr").find("input[name='grantType']").val();
				if (grant_type=="C") {
					$(obj).attr("disabled", "true");
				}
			});

		}


		function showCreditDetail(prpCode){
			var uniqueId = $("#uniqueId_" + prpCode).val();
			var zh_name = $("#zh_name_" + prpCode).val();
			var executionOrg = $("#executionOrg_" + prpCode).val();
			var infodate = $("#infodate_" + prpCode).val();
			var executionNo = $("#executionNo_" + prpCode).val();
			var farenOrnot = $("#farenOrnot_" + prpCode).val();
			var card_type = $("#card_type_" + prpCode).val();
			var card_code = $("#card_code_" + prpCode).val();
			var effect_name = $("#effect_name_" + prpCode).val();
			var zh_title = $("#zhTitle_" + prpCode).val();
			var grant_name = $("#grant_name_" + prpCode).val();
			tb_show("失信检查结果","${ctx}/credit/showCreditDialog?prpCode=" + prpCode
					+"&uniqueId="+uniqueId+"&zh_name="+zh_name+"&executionOrg="+executionOrg+"&infodate="+infodate+"&executionNo="+executionNo
					+"&farenOrnot="+farenOrnot+"&card_type="+card_type+"&card_code="+card_code+"&effect_name="+effect_name+"&zh_title="+zh_title+"&grant_name="+grant_name
					+ "&flag=1&TB_iframe=true&height=460&width=824", false);
		}



		function cleanQueryBox(){
			$("[id^='_dyn_criteria'][id$='_c']", "#prpApprove_search4org").each(function(){
				$(this).children().each(function(){
					$(this).val('');
				});
			});
		}

		function viewComment(des3Prpcode){
			var url="${ctx}/proposal/view/audit-comment-view?posCode="+des3Prpcode+"&TB_iframe=true&height=390&width=720";
			var title="审核意见";
			showThickBox(url,title);
		}

		/**检查选中项目限项设置**/
		function checklimitInfo(grantcodeStr,statYearStr){
			var checked = 1;
			var msg = "";
			if(grantcodeStr!=""&&'${limitinfo}'!=''){
				grantcodeStr = grantcodeStr.substring(1);
				statYearStr = statYearStr.substring(1);
				var linfoArr = '${limitinfo}'.split(",");
				for(var i=0;i<linfoArr.length;i++){
					var sublinfoArr = linfoArr[i].split("##");//grant_code##grant_name##limit_count##approved_count
					var grantCode1 = sublinfoArr[0];
					var grantName = sublinfoArr[1];
					var limitCount = sublinfoArr[2];
					var approvedCount = sublinfoArr[3];
					var statYear = sublinfoArr[4];
					var grantcodeArr = grantcodeStr.split(",");
					var statYearArr = statYearStr.split(",");
					var selected = 0;
					for(var j=0;j<grantcodeArr.length;j++){
						if(grantcodeArr[j]==grantCode1 && statYearArr[j]==statYear){
							selected++;
						}
					}
					if(selected>0){
						var checkNum = parseInt(approvedCount)+selected;
						if(checkNum>parseInt(limitCount)){
							checked = 0;
							var shen = parseInt(limitCount,10)-parseInt(approvedCount,10);
							if(shen<0){
								shen = 0;
							}
							msg = "您单位申报"+statYear+"年度"+grantName+"类别的项目仅能申报"+limitCount+"项，目前已经上报了"+approvedCount+"项，还能上报"+shen+"项.";
							break;
						}
					}
				}
			}
			if(checked>0){
				return true;
			}
			scmWarn(msg, null, 7000);
			return false;

		}

		//审核页面调用该方法刷新页面
		function search(){
			$("#searchBt").click();
		}


		/**查看单位信息*/
		function orgInfoView(orgCode){
			//$("#orgCode").val(orgCode);
			//$("#mainForm").submit();
			tb_show("查看单位信息","${ctx}/orgmanage/verifyorg/org-info-view?orgCode=" + orgCode
					+ "&TB_iframe=true&height=460&width=950", false);
		}

		function showReportDialog(){
			var searchString=jQuery('#dataGrid').jqGrid('getGridParam','postData')['searchString'];
			tb_show("打印汇总表","${ctx}/prpapprove/list-for-report"+"?searchString="+encodeURIComponent(searchString)+"&TB_iframe=true&height=460&width=1024", false);
		}

		function viewPrpCheckResults(prpCode){
			tb_show("规则检查结果","${ctx}/prpapprove/prp-check-result?prpCode=" + prpCode
					+ "&TB_iframe=true&height=460&width=824", false);
		}

		function showPrpSimilarView(prpCode){
			tb_show("","${ctx}/prpapprove/prp-similar-list?prpCode=" + prpCode +"&TB_iframe=true&height=460&width=820",false);
		}
		/**查看单位信息*/
		function orgResembleView(orgCode,prpCode){
			//$("#orgCode").val(orgCode);
			//$("#mainForm").submit();
			var height = window.screen.height;
			var width = window.screen.width;
			tb_show("查看疑似单位信息","${ctx}/prpapprove/list-resemble-org?orgCode=" + orgCode
					+"&prpCode="+prpCode
					+"&TB_iframe=true&height="+height*0.8+"&width="+width*0.9+"", false);

		}
		/** 显示工作进度 */
		function showPrjProgress(keyCode,progressCode){
			var url = ctx + "/prpapprove/showPrjProgress";
			url = url + "?keyCodeStr="+keyCode+"&progressCode="+progressCode;
			url = url + "&TB_iframe=true&height=500&width=700";
			tb_show("工作进度",url, false);
		}
		function setGray() {
			<security:authorize ifAnyGranted="A_AUTH_TJBM,A_AUTH_ADMIN">
			$("input[name^='jqg_dataGrid_']").each(function(){
				$(this).attr('disabled',true);
				$(this).css("background-color", "#e6e6e6");
			});
			//检查比对结果
			interval2();
			</security:authorize>

			<security:authorize ifNotGranted="A_AUTH_TJBM,A_AUTH_ADMIN">
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				var grant_type = $(this).parents("tr").find("input[name='grantType']").val();
				if (grant_type=="C") {
					$(obj).attr("disabled", "true");
				}
			});
			</security:authorize>
		}
		function checkSelectAll() {
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if ($(obj).attr("disabled")) {
					$(obj).attr("checked", false);
				}
			});
		}

		function checkSelectAll2(selectId2) {
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				var selectId=obj.id.replace("jqg_dataGrid_", "");
				if(selectId==selectId2&&$(obj).attr("disabled")){
					$(obj).attr("checked", false);
				}
			});
		}

</script>
</body>
</html>